package com.yanqu.road.server.cmd.marriage;

import com.yanqu.road.entity.servercenter.group.CrossMarriageGroup;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.marriage.CrossMarriageProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.marriage.CrossGroupMarriageMgr;
import com.yanqu.road.server.manger.CrossMarriageGroupMgr;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_MARRIAGE_BLACKLIST_REMOVE_APPOINT, desc = "黑名单处理跨服指向联姻")
public class CrossMarriageBlacklistRemoveAppointCmd extends CrossCommand {
    private long userId;
    private long blacklistUserId;
    private long blacklistServerId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossMarriageProto.CrossMarriageBlacklistRemoveAppointReqMsg reqMsg = CrossMarriageProto.CrossMarriageBlacklistRemoveAppointReqMsg.parseFrom(packet.getBytes());
        blacklistUserId = reqMsg.getBlacklistUserId();
        blacklistServerId = reqMsg.getBlacklistServerId();
        userId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossMarriageGroup marriageGroup = CrossMarriageGroupMgr.getCrossMarriageGroupByServerId(serverId);
        if(!CrossMarriageGroupMgr.canCrossMarriage(marriageGroup)){
            return;
        }
        CrossGroupMarriageMgr.blacklistRemoveAppointMarriage(marriageGroup.getGroupId(), serverId, userId, blacklistUserId, blacklistServerId);
    }

    @Override
    public void sendData() {

    }
}
